-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Local CAS now uses IPFS-compatible CIDs #411
Conversation
Codecov Report
@@ Coverage Diff @@
## main #411 +/- ##
==========================================
- Coverage 89.13% 89.00% -0.13%
==========================================
Files 93 93
Lines 6184 6202 +18
==========================================
+ Hits 5512 5520 +8
- Misses 392 400 +8
- Partials 280 282 +2
Continue to review full report at Codecov.
|
d0ab325
to
c408f5c
Compare
Now that CIDs are the same as IPFS can you enable announce test? Look for: """ TODO: Enable this test when CIDs for ipfs and local CAS are identical |
@sandrask I enabled it and it worked. However... Per an earlier discussion with @troyronda, for this commit I'm not going to be actually changing over the format yet. The reason is to make sure that I'm not changing the sample CIDs that we're submitting to the test suite before having proper default v1 support. So while I have tested locally with my new compatible v0 CIDs enabled, for this PR I need to leave it disabled. I'll re-enable it in #344 |
pkg/store/cas/cas.go
Outdated
cid = merkledag.NodeWithData(unixfs.FilePBData(content, uint64(len(content)))).Cid().String() | ||
} else { | ||
prefix := gocid.Prefix{ | ||
Version: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why version 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- That's what it was set to before.
- That's what our current IPFS client does. I need to update it in another PR to start using v1 as well...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(changing it to v1 will break the current sample CIDs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current sample CIDs seem
incorrect, being neither an accepted v0 nor a v1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are/ where are the current sample CIDs? Maybe they were produced using the current (faulty) v0 generation in Orb?
In a previous PR I updated the CID in a sample create activity in our BDD tests, but that was to match the CID output by IPFS (by default), so it should be valid. https://github.com/trustbloc/orb/pull/339/files#r626128523
@@ -112,7 +112,6 @@ Feature: | |||
Then the JSON path "type" of the response equals "CollectionPage" | |||
And the JSON path "items" of the response does not contain "${domain2IRI}" | |||
|
|||
""" TODO: Enable this test when CIDs for ipfs and local CAS are identical |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sandrask Actually, per a follow-up discussion with @troyronda it looks like we need to make the CIDs we produce compatible with IPFS now. v1 CIDs are now the default and they work with IPFS. I re-enabled the tests again and they pass.
cmd/orb-server/startcmd/params.go
Outdated
@@ -629,6 +649,7 @@ func createFlags(startCmd *cobra.Command) { | |||
startCmd.Flags().StringP(httpSignaturesEnabledFlagName, httpSignaturesEnabledShorthand, "", httpSignaturesEnabledUsage) | |||
startCmd.Flags().StringP(casTypeFlagName, casTypeFlagShorthand, "", casTypeFlagUsage) | |||
startCmd.Flags().StringP(ipfsURLFlagName, ipfsURLFlagShorthand, "", ipfsURLFlagUsage) | |||
startCmd.Flags().String(cidVersionFlagName, "0", cidVersionFlagUsage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean to default to "0" if not provided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, yes you're correct. That should be "1". I've fixed it now.
@@ -74,7 +74,7 @@ func TestRead(t *testing.T) { | |||
})) | |||
defer ipfs.Close() | |||
|
|||
cas := New(ipfs.URL) | |||
cas := New(ipfs.URL, false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing test with true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I also noticed that the "success" test was using a mocked server. Since I already went to the work of using a real IPFS server in the cas_test.go
tests, I updated it to use a real IPFS server as well.
if p.useV0CIDs { | ||
// The v0 CID produced below is equal to what an IPFS node would produce, assuming that: | ||
// 1. The IPFS node is running with default settings, and | ||
// 2. The size of the content passed in here is less than 256KB (the default chunk size). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a plan to make it work with content > 256KB? If there is a plan maybe we should create an issue to track this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created an issue: #418
8ee9c32
to
87e920a
Compare
The local CAS now uses CIDs that are compatible with IPFS, assuming that the IPFS node is running under default settings and that the data is less than 256KB. A new flag was added to choose between v1 or v0 CIDs. The IPFS client will also use this format now. v1 CIDs are the default. Signed-off-by: Derek Trider <[email protected]>
The local CAS now uses CIDs that are compatible with IPFS, assuming that the IPFS node is running under default settings and that the data is less than 256KB.
A new flag was added to choose between v1 or v0 CIDs. The IPFS client will also use this format now. v1 CIDs are the default.
Signed-off-by: Derek Trider [email protected]
closes #318